"""
Other utility functions for the Soya GUI
"""

import os, sys, os.path

from constants import DATA_DIR_NAME

def findDataDir():
    curpath = os.path.dirname(sys.argv[0])
    while curpath:
        if os.path.exists(os.path.join(curpath, DATA_DIR_NAME)):
            dataPath = os.path.join(curpath, DATA_DIR_NAME)
            break
        
        curpath, tail = os.path.split(curpath)
    else:
        #No path found, use a default...
        dataPath = os.path.join(os.path.expandvars('$HOME'), '.pgame')
    if not os.path.isdir(dataPath):
        raise ValueError, "Couldn't find my data!"
    return dataPath